using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;


namespace IGlobalist.Cms.Admin.Control
{
    public partial class Login : AdminBaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (IGlobalistMembership.IsAuthenticate)
                {
                    mvLogin.SetActiveView(vLogout);
                    BindUserInfo();
                }
            }
           
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            if (IGlobalistMembership.ValidateUser(username, password)) {
                mvLogin.SetActiveView(vLogout);
            };
        }

        private void BindUserInfo()
        {
            lblLoggedName.Text = IGlobalistMembership.Fullname;
        }

        protected void lbLogout_Click(object sender, EventArgs e)
        {
            IGlobalistMembership.Logout();
            mvLogin.SetActiveView(vLogin);
        }
    }
}